package com.lrs.java.dataStructure.linkList;

class LinkStack {
	private LinkList list;

	public LinkStack() {
		list = new LinkList();
	}

	public void push(int j) {
		list.insertFirst(j, j+0.0);
	}

	public long pop() {
		return list.removeFirst().getiData();
	}

	public boolean isEmpty() {
		return (list.isEmpty());
	}

	public void displayStack() {
		System.out.print("Stack (top-->bottom): ");
		list.display();
	}
}

class LinkStackApp {
	public static void main(String[] args) {
		LinkStack theStack = new LinkStack(); // make stack

		theStack.push(20); // push items
		theStack.push(40);

		theStack.displayStack(); // display stack

		theStack.push(60); // push items
		theStack.push(80);

		theStack.displayStack(); // display stack

		theStack.pop(); // pop items
		theStack.pop();

		theStack.displayStack(); // display stack
	}
}

